package com.artpri.dao.impl;

import com.artpri.dao.UserDao;
import com.artpri.model.UserInfo;

/**
 * 
 * @author ZhangSi
 *
 */
public class UserDaoImpl extends HibernateDaoImpl<UserInfo> implements UserDao{

	@Override
	public UserInfo checkEmailUser(String user, String pass) {
		return (UserInfo) getQuery("from UserInfo u where u.userEmail=?0 and u.userPasswd=?1", user, pass).uniqueResult();
	}

	@Override
	public UserInfo checkMobileUser(String user, String pass) {
		return (UserInfo) getQuery("from UserInfo u where u.userPhone=?0 and u.userPasswd=?1", user, pass).uniqueResult();
	}

	@Override
	public Integer checkUserNameExists(String name) {
		return findCount("select count(*) from UserInfo u where u.userName=?0", name);
	}

	@Override
	public UserInfo getUserByEmail(String email) {
		return (UserInfo) getQuery("from UserInfo u where u.userEmail=?0", email).uniqueResult();
	}

	@Override
	public UserInfo getUserByMobile(String mobile) {
		return (UserInfo) getQuery("from UserInfo u where u.userPhone=?0", mobile).uniqueResult();
	}

}
